package com.cskaoyan.demo;

import com.cskaoyan.bean.Student;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.*;

public class Demo2 {
    public static void main(String[] args) throws IOException {
        Student s = new Student("小明", 1, "123456");
        ObjectMapper objectMapper = new ObjectMapper();
        String stuStr = objectMapper.writeValueAsString(s);
        OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(new File("stu1.txt")));

        writer.write(stuStr);
        writer.close();


    }
}
